package com.eliza.springboot.v3.http.config

import org.springframework.context.annotation.Configuration
import org.springframework.http.CacheControl
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer
import java.util.concurrent.TimeUnit

//配置方式1 继承实现

//@EnableWebMvc  //禁用boot的默认配置
@Configuration(proxyBeanMethods = false)
class MyWebConfiguration : WebMvcConfigurer {
    override fun addResourceHandlers(registry: ResourceHandlerRegistry) {
//       之前的规则
        super.addResourceHandlers(registry)
//       自定义规则

//        registry.addResourceHandler("/static/**")
//            .setCacheControl(CacheControl.maxAge(1000, TimeUnit.SECONDS))
    }
}